# 代码所有：cxw
# 开发时间：2021/11/11 21:50

def read_openfile(filename):
    try:
        with open(filename) as files:
            contens=files.read()
    except FileNotFoundError:
        print("文件未找到，请核实文件正确位置")
        #
    else:
        print(contens)
filename="test_file/cat.txt"
read_openfile(filename)
filename="nam.txt"  #文件不存在，使用except后的代码
read_openfile(filename)